package com.example.shixunandjavagotoyangchen.BoosYang.Day002;

import android.util.Log;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;

import com.example.modelviewpresenter.View.BasterFragment;
import com.example.shixunandjavagotoyangchen.BoosYang.Day002.Day002_11012.ChaotongAdpter;
import com.example.shixunandjavagotoyangchen.BoosYang.Day002.Day002_11012.ChaotongBean;
import com.example.shixunandjavagotoyangchen.BoosYang.Day002.Day002_11012.ChaotongContion;
import com.example.shixunandjavagotoyangchen.BoosYang.Day002.Day002_11012.ChaotongModel;
import com.example.shixunandjavagotoyangchen.BoosYang.Day002.Day002_11012.ChaotongPresenter;
import com.example.shixunandjavagotoyangchen.BoosYang.Day002.Day002_11013.GoodthingAdpter;
import com.example.shixunandjavagotoyangchen.BoosYang.Day002.Day002_11013.GoodthingBean;
import com.example.shixunandjavagotoyangchen.BoosYang.Day002.Day002_11013.GoodthingContion;
import com.example.shixunandjavagotoyangchen.BoosYang.Day002.Day002_11013.GoodthingModel;
import com.example.shixunandjavagotoyangchen.BoosYang.Day002.Day002_11013.GoodthingPresenter;
import com.example.shixunandjavagotoyangchen.BoosYang.Day002.Day002_1104.WomenswearAdpter;
import com.example.shixunandjavagotoyangchen.BoosYang.Day002.Day002_1104.WomenswearBean;
import com.example.shixunandjavagotoyangchen.R;
import com.scwang.smart.refresh.layout.SmartRefreshLayout;
import com.scwang.smart.refresh.layout.api.RefreshLayout;
import com.scwang.smart.refresh.layout.listener.OnRefreshLoadMoreListener;

import java.util.List;


public class BlankFragmentDay002_11013 extends BasterFragment implements OnRefreshLoadMoreListener, GoodthingContion.vier {


    public static SmartRefreshLayout GoodthingSmartRefreshLayout;
    private RecyclerView GoodthingRecyclerView;
    public boolean issdd= true;
    public GoodthingAdpter adpter;
    public GoodthingPresenter presenter;

    @Override
    public int BandLayout() {
        return R.layout.fragment_blank_fragment_day002_11013;
    }

    @Override
    public void initView() {

        GoodthingSmartRefreshLayout = (SmartRefreshLayout) findViewById(R.id.Goodthing_SmartRefreshLayout);
        GoodthingRecyclerView = (RecyclerView) findViewById(R.id.Goodthing_RecyclerView);
        GoodthingRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(3,StaggeredGridLayoutManager.VERTICAL));
        GoodthingSmartRefreshLayout.setOnRefreshLoadMoreListener(this);
        presenter = new GoodthingPresenter(this,new GoodthingModel());
        presenter.goodting("Home_zidingyi.php");
    }

    @Override
    public void initDate() {

    }


    @Override
    public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
        issdd =false;
        refreshLayout.finishLoadMore();
        refreshLayout.finishRefresh();
    }

    @Override
    public void onRefresh(@NonNull RefreshLayout refreshLayout) {

        if (issdd){
            Log.i("aaa","la1");
        }
        refreshLayout.finishLoadMore();
        refreshLayout.finishRefresh();

    }

    @Override
    public void getvier(List<GoodthingBean.ShujuBean> dataBeans) {
        GoodthingSmartRefreshLayout.finishLoadMore();
        GoodthingSmartRefreshLayout.finishRefresh();
        if (adpter==null){
            adpter = new GoodthingAdpter(dataBeans);
            GoodthingRecyclerView.setAdapter(adpter);
        }else {
            if (issdd){
                adpter.getData().clear();
            }
            adpter.getData().addAll(dataBeans);
            adpter.notifyDataSetChanged();
        }
    }
}
